package com.zlj.springcloud.controller;

import com.zlj.springcloud.entity.Dept;
import com.zlj.springcloud.service.DeptClientService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @Description: Dept消费者(使用Feign)
 * @Author: zlj
 * @CreateDate: 2018/6/19 11:53
 * @Version: 1.0.0
 */
@RestController
@RequestMapping("/feign")
public class DeptController_Consumer {

    private final DeptClientService deptClientService;

    public DeptController_Consumer(DeptClientService deptClientService) {
        this.deptClientService = deptClientService;
    }

    @PostMapping("/consumer/dept/add")
    public boolean add(Dept dept) {
        return deptClientService.add(dept);
    }

    @GetMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id) {
        return deptClientService.get(id);
    }

    @GetMapping("/consumer/dept/list")
    public List<Dept> list() {
        return deptClientService.list();
    }
}
